package com.itstyle.seckill.topic.desinger.design_cj.factory.invoke;

/**
 * @Auther: liuwenxiang
 * @Date: 2020/3/11 12:39
 * @Description:
 */
public class ConcreteCreator implements Creator {
    @Override
    public <T extends Product> T createProduct(Class<T> tClass) {
        Product product =null;
        try {
            product = (Product) tClass.newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }

        return (T)product;
    }

    public static void main(String[] args) {
        Creator creator = new ConcreteCreator();

        Product productA = creator.createProduct(ConcreteProductA.class);
        productA.doSomething();
        productA.doAnything();
    }
}
